import { defineStore } from 'pinia'
export const useUserStore = defineStore({
  id: 'user',
  state: () => {
    return {
      token: "",
      userInfo: {}
    }
  },
  actions: {
    //设置token
    setToken (token) {
      this.token = token
    },
    //存储userinfo
    setuserInfo (payload) {
      this.userInfo = payload
    },
    //清除token
    removeToken () {
      this.token = ''
      this.userInfo = {}
    }
  },
  persist: {
    enabled: true,
    strategies: [{
      key: 'xiaoluxian_user',
      storage: localStorage,
    }]
  }
})